<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:h="http://java.sun.com/jsf/html">

<h:head>
	<title>openMEDIS</title>
</h:head>

<ui:composition template="/WEB-INF/templates/main.xhtml">
	<ui:define name="content">
		<h:form id="mainForm">
			<p:panel header="New Device" style="border: none;" collapsed="true" />

			<h:panelGrid id="main" columns="4">
				<h:outputLabel value="Equipment category: *" />
				<h:selectOneMenu id="category"
					value="#{testBean.dev.assetcategory1}">
					<f:selectItems value="#{testBean.categoryList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Equipment name: *" />
				<p:inputText id="name"
					value="#{assetsController.viewBean.currentAsset.umdns.genericAssetName}"
					required="true" requiredMessage="Name is requied"
					validatorMessage="Please enter alphabets only (minimum 3 signs)">
					<f:validateRegex pattern="[a-zA-Z]*" />
					<f:validateLength minimum="3" maximum="30" />
				</p:inputText>
				<p:commandButton id="basic" value="Search"
					oncomplete="dlgFindUmdns.show()" update="childForm" />
				<p:message for="name"></p:message>

				<h:outputLabel value="Equipment full name: *" />
				<p:inputText id="full" value="#{testBean.dev.assetFullName}"
					required="true" requiredMessage="Full name is requied"
					validatorMessage="Please enter alphabets only (minimum 3 signs)">
					<f:validateRegex pattern="[a-zA-Z]*" />
					<f:validateLength minimum="3" maximum="30" />
				</p:inputText>
				<h:outputText />
				<p:message for="full"></p:message>

				<h:outputLabel value="UMDNS code: *" />
				<p:inputText id="code"
					value="#{assetsController.viewBean.currentAsset.umdns.genericAssetCode}"
					required="true" requiredMessage="Code is requied" />
				<h:outputText />
				<p:message for="code"></p:message>




				<h:outputLabel value="Manufacturer: *" />
				<h:selectOneMenu id="manufacturer"
					value="#{testBean.dev.manufactures}">
					<f:selectItems value="#{testBean.manufacturerList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Model: *" />
				<p:inputText id="model" value="#{testBean.dev.model}"
					required="true" requiredMessage="Model name is requied"
					validatorMessage="Please enter minimum 2 signs">
					<f:validateLength minimum="2" maximum="30" />
				</p:inputText>
				<h:outputText />
				<p:message for="model"></p:message>

				<h:outputLabel value="Date of Purchasing: *" />
				<p:calendar id="purchaseDate" value="#{testBean.dev.purchaseDate}"
					maxdate="#{testBean.today}" navigator="true" required="true"
					requiredMessage="Release date is requied" pattern="yyy.MM.dd"
					validator="#{testBean.checkDate}" />
				<h:outputText />
				<p:message for="purchaseDate" />

				<h:outputLabel value="Lifetime (years): *" />
				<h:selectOneMenu id="lifetime" value="#{testBean.dev.lifetime}">
					<f:selectItems value="#{testBean.lifetimeList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Serial number: *" />
				<p:inputText id="serialNumber" value="#{testBean.dev.serialNumber}"
					required="true" requiredMessage="Serial number is requied" />
				<h:outputText />
				<p:message for="serialNumber"></p:message>

				<h:outputLabel value="Inventory number: *" />
				<p:inputText id="inventoryNumber"
					value="#{testBean.dev.internalIventoryNumber}" required="true"
					requiredMessage="Inventory number is requied" />
				<h:outputText />
				<p:message for="inventoryNumber"></p:message>

				<h:outputLabel value="Installation date: *" />
				<p:calendar id="installationDate"
					value="#{testBean.dev.installationDate}"
					maxdate="#{testBean.today}" navigator="true" required="true"
					requiredMessage="Purchase date is requied" pattern="yyy.MM.dd"
					validator="#{testBean.checkDate}" />
				<h:outputText />
				<p:message for="installationDate" />

				<h:outputLabel value="Funding: " />
				<h:selectOneMenu id="funding" value="#{testBean.dev.donors}">
					<f:selectItems value="#{testBean.fundingList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Purchase price: *" />
				<p:inputText id="purchasePrice"
					value="#{testBean.dev.purchasePrice}" required="true"
					requiredMessage="Purchase price is requied"
					validator="#{testBean.checkCode}" />
				<h:outputText />
				<p:message for="purchasePrice"></p:message>

				<h:outputLabel value="Remaining value: *" />
				<p:inputText id="remainingValue"
					value="#{testBean.dev.currentValue}" required="true"
					requiredMessage="Remaining value is requied"
					validator="#{testBean.checkCode}" />
				<h:outputText />
				<p:message for="remainingValue"></p:message>

				<h:outputLabel value="Supplier: *" />
				<h:selectOneMenu id="supplier" value="#{testBean.dev.suppliers}">
					<f:selectItems value="#{testBean.supplierList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Warranty of Contract: *" />
				<h:selectOneMenu id="contractWarranty"
					value="#{testBean.dev.warrantycontract}">
					<f:selectItems value="#{testBean.warrantyOfContractList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Warranty Contract Expiry: *" />
				<p:calendar id="contractWarrantyExpiry"
					value="#{testBean.dev.warrantyContractExp}" navigator="true"
					required="true"
					requiredMessage="Warranty Contract Expiry date is requied"
					pattern="yyy.MM.dd" validator="#{testBean.checkDate1}" />
				<h:outputText />
				<p:message for="contractWarrantyExpiry" />

				<h:outputLabel value="Warranty Contract Notes: " />
				<p:inputTextarea style="width:300px;height:100px;"
					effectDuration="400" id="contractWarrantyNotes"
					value="#{testBean.dev.warrantyContractNotes}" />
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Service Agent: *" />
				<h:selectOneMenu id="serviceAgent" value="#{testBean.dev.agents}">
					<f:selectItems value="#{testBean.serviceAgentList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Technicain: *" />
				<h:selectOneMenu id="technician" value="#{testBean.dev.employees}">
					<f:selectItems value="#{testBean.technicianList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Location: *" />
				<h:selectOneMenu id="location" value="#{testBean.dev.location}">
					<f:selectItems value="#{testBean.locationList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Person Responsible: *" />
				<h:selectOneMenu id="personResponsible"
					value="#{testBean.dev.employees}">
					<f:selectItems value="#{testBean.technicianList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Status: *" />
				<h:selectOneMenu id="status" value="#{testBean.dev.assetstatus}">
					<f:selectItems value="#{testBean.statusList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Utilization: *" />
				<h:selectOneMenu id="utilization"
					value="#{testBean.dev.assetutilization}">
					<f:selectItems value="#{testBean.utilizationList}" />
				</h:selectOneMenu>
				<h:outputText />
				<h:outputText />

				<h:outputLabel value="Notes: " />
				<p:inputTextarea style="width:300px;height:100px;"
					effectDuration="400" id="notes" value="#{testBean.dev.notes}" />
				<h:outputText />

			</h:panelGrid>
			<p:commandButton action="#{testBean.saveDevice}" ajax="false"
				value="save device"></p:commandButton>
		</h:form>
	</ui:define>

	<ui:define name="outOfLayout">
		<!-- Dialog is lazy loaded because of dynamic="true" -->
		<p:dialog widgetVar="dlgFindUmdns" header="Find UMDNS" modal="true"
			dynamic="true" resizable="false">
			<h:form id="formFindUmdns">
				<h:panelGrid>
					<h:panelGrid columns="2" width="100%" style="text-align: right;">
						<p:inputText id="search"
							value="#{umdnsController.viewBean.searchString}"
							style="margin-right: 2px; height: 14px; width: 110%"></p:inputText>
						<p:commandButton image="ui-icon ui-icon-search"
							actionListener="#{umdnsController.findUmdns}"
							update="formFindUmdns"
							style="height: 25px; margin-top: 1px; width: 25px;"></p:commandButton>
					</h:panelGrid>

					<p:dataTable value="#{umdnsController.umdnsTable.umdnsList}"
						var="item" emptyMessage="No UMDNS codes were found"
						paginator="true" paginatorPosition="bottom"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rows="20" rowsPerPageTemplate="20, 50, 100, 200, 500"
						pageLinks="5" scrollable="true" scrollHeight="400"
						selection="#{umdnsController.umdnsTable.selectedUmdns}"
						selectionMode="single" rowKey="#{item.genericAssetId}">
						<p:column headerText="Code">
							<h:outputText value="#{item.genericAssetCode}" />
						</p:column>
						<p:column headerText="Name">
							<h:outputText value="#{item.genericAssetName}" />
						</p:column>
						<p:column headerText="Picture">
							<h:outputText value="#{item.genericPicture}" />
						</p:column>
					</p:dataTable>
					<h:panelGroup style="text-align: right; display: block;">
						<p:commandButton value="Cancel" type="button"
							onclick="dlgFindUmdns.hide(); "></p:commandButton>
						<p:commandButton value="Ok"
							actionListener="#{assetsController.setUmdns}"
							oncomplete="dlgFindUmdns.hide();"
							update="mainForm:code"></p:commandButton>
					</h:panelGroup>
				</h:panelGrid>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>
</html>